<template>
  <view class="margin">
    <view-navbar></view-navbar>
    <view class="" style="height: 40rpx"> </view>
    <view class="">
      <h1 v-if="authStatus != '1' && authStatus != '2'">认证中....</h1>
      <h1 v-if="authStatus == '2'">认证失败....</h1>
    </view>

    <view
      class="fa mt20"
      @click="$pub.go('/pages/hos/doctorConfirm/doctorConfirm')"
    >
      <view class="fa f1" v-if="authStatus != '2'">
        <image
          src="/static/img/server.png"
          mode="widthFix"
          class="wid15 mr10"
        ></image>
        医生认证
      </view>
      <view class="fa f1" v-if="authStatus == '2'">
        <image
          src="/static/img/server.png"
          mode="widthFix"
          class="wid15 mr10"
        ></image>
        <!-- 重新认证重新认证 -->
		退出登录
      </view>
      <image src="/static/img//rit.png" mode="widthFix" class="wid6"></image>
    </view>
	
	<view
	  class="fa mt20"
	  @click="loginOut"
	>
	  <view class="fa f1" >
	    <image
	      src="/static/img/server.png"
	      mode="widthFix"
	      class="wid15 mr10"
	    ></image>
		退出登录
	  </view>
	  <image src="/static/img//rit.png" mode="widthFix" class="wid6"></image>
	</view>
	
	
	
  </view>
</template>

<script>
export default {
  data() {
    return {
      authStatus: "",
    };
  },
  onPullDownRefresh: function() {
      console.log('我被下拉了');
      //这里做页面刷新数据请求事件，例如重新请求接口
      //建议重置一些参数
      this.getPageList()
  },
  onLoad() {
  	 uni.startPullDownRefresh() // 监听下拉刷新事件
  },
  methods: {
	  /* */
	  async getPageList(){
			 let res = await this.$API.doctorApi.doctorAuth();
			 /* */
			 uni.setStorageSync("authStatus", res.applyStatus);
			 /* */
			this.authStatus = uni.getStorageSync('authStatus')
			let token = uni.getStorageSync('token')

			if (this.authStatus == "0" || this.authStatus === null && !token ) {
			  console.log("未认证");
			  uni.showToast({
			  	title:'还未认证，请等待ing'
			  })
			} else if (this.authStatus == "1") {
			  console.log("认证页面");
			  uni.reLaunch({
			    url: "/pages/index/index",
			  });
			}
	      //请求接口方法
	      //接口返回成功或失败后
	      // 关闭下拉刷新的效果
	      uni.stopPullDownRefresh()
	},
	/*  */
	loginOut() {
		console.log('退出登录');
		uni.clearStorageSync();
		// uni.removeStorage()
		
		// uni.removeStorageSync('token')
		// uni.removeStorageSync('userInfo')
		// uni.removeStorageSync('ID')
		uni.reLaunch({
			url: '/pages/index/index'
		})
	}
  },
};
</script>

<style lang="scss">
</style>